package cn.tedu.review;

public class TestAnimal2 {
    public static void main(String[] args) {
        Insect a=new Insect();
        System.out.println(a.legNum);
        System.out.println(a.eggNum);
        a.fly();
        a.spawn();
        System.out.println("_____________");

        Ant a1=new Ant();
        System.out.println(a1.legNum);
        System.out.println(a1.eggNum);
        a1.fly();
        a1.spawn();
        System.out.println("_____________");

        Bee a2=new Bee();
        System.out.println(a2.legNum);
        System.out.println(a2.eggNum);
        a2.fly();
        a2.spawn();
        System.out.println("_____________");
    }
}
class Insect{
    int legNum=6;
    int eggNum;
    public void fly(){
        System.out.println("昆虫会飞");
    }
    public void spawn(){
        System.out.println("昆虫会产卵");
    }
}
class Ant extends Insect{
    public void fly(){
        System.out.println("部分蚂蚁也会飞");
    }
    public void spawn(){
        System.out.println("蚁后专门产卵");
    }
}
class Bee extends Insect{
    public void fly(){
        System.out.println("蜜蜂经常飞来飞去的采蜜");
    }
    public void spawn(){
        System.out.println("蜂后专门产卵");
    }
}
